package com.troll.wanandroid.adapter.system

import com.chad.library.adapter.base.BaseNodeAdapter
import com.chad.library.adapter.base.entity.node.BaseNode
import com.troll.wanandroid.model.SystemKnowledge
import com.troll.wanandroid.model.SystemKnowledgeTag

/**
 *
 * @Author:   TangPeng
 * @Time:     6/10/21
 * @Remark:
 */
class SystemAdapter : BaseNodeAdapter {

    companion object {
        const val SYSTEM_NODE_TITLE = 1
        const val SYSTEM_NODE_TAG = 2
    }

    constructor() : super() {
        addFullSpanNodeProvider(SystemTitleProvider())
        addNodeProvider(SystemTagProvider())
    }

    override fun getItemType(data: List<BaseNode>, position: Int): Int {
        when (data[position]) {
            is SystemKnowledge -> return SYSTEM_NODE_TITLE
            is SystemKnowledgeTag -> return SYSTEM_NODE_TAG
        }
        return -1
    }
}